import request from "@/utils/request"

//1,查询分页列表数据

//查询分页列表参数类型
export interface reqTrademarkListParamsType {
    page: number;
    limit: number;
}
//查询返回值中records中每一项数据类型
export interface reqTrademarkListRecordsItemType {
    id: number;
    tmName: string;
    logoUrl: string;
}
//查询返回值records数据类型
export type reqTrademarkListRecordsType = reqTrademarkListRecordsItemType[]

//查询分页列表返回值类型
export interface reqTrademarkListReturnType {
    records: reqTrademarkListRecordsType;
    total: number;
    size: number;
    current: number;
    searchCount: boolean;
    pages: number;
}
//查询分页列表函数
export const requestTrademarkList = ({ page, limit }: reqTrademarkListParamsType) => {
    return request.get<any, reqTrademarkListReturnType>(`/admin/product/baseTrademark/${page}/${limit}`)
}

//2,新增Trademark请求
//新增trademark body参数类型
export interface reqAddtrademarkParamsType {
    logoUrl: string;
    tmName: string;
}
//新增trademark请求函数
export const requestAddtrademark = (newTrademark: reqAddtrademarkParamsType) => {
    return request.post("/admin/product/baseTrademark/save", newTrademark)
}

//3,修改trademark请求
//修改trademark请求的body参数类型
export interface reqUpdatetrademarkParamsType {
    id: 0;
    logoUrl: string;
    tmName: string;
}
//修改trademark请求函数
export const requestUpdatetrademark = (currentTrademarkInfo:reqUpdatetrademarkParamsType) => {
    return request.put("/admin/product/baseTrademark/update", currentTrademarkInfo)
}

//4,删除trademark请求

//删除trademark请求函数
export const requestDeleteTrademark = (id:number) => {
    return request.delete(`/admin/product/baseTrademark/remove/${id}`)
}

//5,获取所有的品牌列表
//返回值类型
 export interface TmListType {
    id: number;
    tmName: string;
    logUrl: string;
 }

export const requestAllTmList = () => {
    return request.get<any, TmListType[]>(
        `/admin/product/baseTrademark/getTrademarkList`
    )
}